package com.zxx.otherchaos;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.zxx.otherchaos.utils.toast.style.ToastAliPayStyle;
import com.zxx.otherchaos.utils.toast.style.ToastQQStyle;
import com.zxx.otherchaos.utils.toast.ToastUtils;
import com.zxx.otherchaos.utils.toast.style.ToastWhiteStyle;
import com.zxx.otherchaos.widgets.progress.ProgressWheel;
import com.zxx.otherchaos.widgets.rickTip.RickyAdapter;
import com.zxx.otherchaos.widgets.rickTip.RickyListView;
import com.zxx.otherchaos.widgets.rickTip.RickyRecycleView;
import com.zxx.otherchaos.widgets.rickTip.RickyRecyclerAdapter;
import com.zxx.otherchaos.widgets.rvScroll.RvHuaDongActivity;

public class MainActivity extends AppCompatActivity implements RickyListView.OnPositionChangedListener, RickyRecycleView.OnPositionChangedListener {

    private RickyListView mListView;
    private RickyRecycleView recycleView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mListView = findViewById(R.id.list);
        mListView.setAdapter(new RickyAdapter(this));
        mListView.setCacheColorHint(Color.TRANSPARENT);
        mListView.setOnPositionChangedListener(this);

        ProgressWheel pw = findViewById(R.id.pw_spinner);
        pw.setText("AAA");
        pw.setProgress(20);
        //pw.spin();

        recycleView = findViewById(R.id.rv);
        LinearLayoutManager manager = new LinearLayoutManager(this);
        recycleView.setLayoutManager(manager);
        recycleView.setAdapter(new RickyRecyclerAdapter(this));
        recycleView.setOnPositionChangedListener(this);
    }

    //---------------吐司
    public void toastBlack(View view) {
        ToastUtils.show("Hello world");
        recycleView.scrollToPosition(0);//直接闪现至某一位位置
    }


    public void toastAlipay(View view) {
        ToastUtils.initStyle(new ToastAliPayStyle(this));
        ToastUtils.show("Ali");
        recycleView.scrollToPosition(-1);
    }

    public void toastWhite(View view) {
        ToastUtils.initStyle(new ToastWhiteStyle(this));
        ToastUtils.show("白色");
        recycleView.smoothScrollToPosition(0);//惯性滑动至某一位置
    }


    public void toastQQ(View view) {
        ToastUtils.initStyle(new ToastQQStyle(this));
        ToastUtils.show("QQ");

        startActivity(new Intent(this, RvHuaDongActivity.class));
    }
    //----------吐司 End

    @Override
    public void onPositionChanged(RickyListView listView, int position, View scrollView) {
        ((TextView) scrollView).setText("" + position);
    }

    @Override
    public void onPositionChanged(RickyRecycleView listView, final int position, View scrollView) {
        ((TextView) scrollView).setText("-" + position);

        scrollView.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));

        //无法点击
        ((TextView) scrollView).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ToastUtils.show("" + position);
                Log.e("Tag-->", "--" + position);
            }
        });

    }
}
